package com.lysh.aliHttp.event;

import com.lysh.aliHttp.common.enums.ProgressEventType;

/**
 * @author liyishan
 * @date 2023/5/5 09:28
 * @apiNote
 */

public class ProgressEvent {
    private final long bytes;
    private final ProgressEventType eventType;

    public ProgressEvent(ProgressEventType eventType) {
        this(eventType, 0L);
    }

    public ProgressEvent(ProgressEventType eventType, long bytes) {
        if (eventType == null) {
            throw new IllegalArgumentException("eventType must not be null.");
        } else if (bytes < 0L) {
            throw new IllegalArgumentException("bytes transferred must be non-negative");
        } else {
            this.eventType = eventType;
            this.bytes = bytes;
        }
    }

    public long getBytes() {
        return this.bytes;
    }

    public ProgressEventType getEventType() {
        return this.eventType;
    }

    public String toString() {
        return this.eventType + ", bytes: " + this.bytes;
    }
}
